<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="../css/center.css" media="all" />
</head>
<body class="gray">
	<div class="mui-content" style="padding-bottom: 20px;">
		<div class="home-top">
	    		<img src="../icon/center@2x.jpg" class="maximg" alt="" />
	    		<div class="name" >
	    			<img src="../icon/default.png" id="heads" class="mui-pull-left" alt="" />
	    			<div>
	    				<h3 class="center" id="showname"></h3>
	    			</div>
	    		</div>
	   </div>
	   <ul class="mui-table-view">
           <li class="mui-table-view-cell link" _id="infor" _href="infor.html" _title="商户信息">
               <a class="mui-navigate-right">
                  商户信息
               </a>
           </li>
           <!--<li class="mui-table-view-cell">
               <a class="mui-navigate-right">
               		<span class="renzhen">未认证<img src="../icon/renzhen2@2x.png" alt="" /></span>
                    我的认证
               </a>
           </li>-->
           <li class="mui-table-view-cell link" _id="account" _href="account.html" _title="账号与安全">
               <a class="mui-navigate-right">
                    账号与安全
               </a>
           </li>
       </ul>
       
       <ul class="mui-table-view">
           <li class="mui-table-view-cell link" _id="about" _href="about.html" _title="关于我们">
               <a class="mui-navigate-right">
                  关于我们
               </a>
           </li>
           <li class="mui-table-view-cell" id="relation" data-phone="">
               <a class="mui-navigate-right">
                    联系客服
               </a>
           </li>
           <!--<li class="mui-table-view-cell">
               <a class="mui-navigate-right">
                   去评分
               </a>
           </li>
           <li class="mui-table-view-cell">
               <a class="mui-navigate-right">
                   分享应用
               </a>
           </li>-->
           <li class="mui-table-view-cell link" _id="feedback" _href="feedback.html" _title="意见反馈">
               <a class="mui-navigate-right">
                   意见反馈
               </a>
           </li>
       </ul>
       
       <ul class="mui-table-view">
           <li class="mui-table-view-cell calcatch">
           		<span class="mb">0M</span>
               清除缓存
           </li>
           <!--<li class="mui-table-view-cell">
           		<span class="version">v1.0.0</span>
               版本号
           </li>-->
       </ul>
       
       <ul class="mui-table-view signoutlist">
           <li class="mui-table-view-cell">
                   退出登录
           </li>
       </ul>
	    
	</div>
<div id="sheet1" class="mui-popover mui-popover-bottom mui-popover-action ">
    <!-- 可选择菜单 -->
    <ul class="mui-table-view">
      <li class="mui-table-view-cell">
        <a href="#" class="callCamera">照相机</a>
      </li>
      <li class="mui-table-view-cell">
        <a href="#" class="callalbum">相册</a>
      </li>
    </ul>
    <!-- 取消菜单 -->
    <ul class="mui-table-view">
      <li class="mui-table-view-cell ">
        <a href="#sheet1" class="sheet1-cancle">取消</a>
      </li>
    </ul>
</div>
<script src="../js/mui.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	var merchant;
	mui.init();
	window.addEventListener('VueShow',function(){
		merchant = bexta.getStorage(MERCHANT);
		document.querySelector('#heads').src = merchant.logo;
		document.querySelector('#showname').innerHTML = merchant.shop_name;
		
		bexta.ajax(api.web_infor, function(res){
			document.querySelector('#relation').setAttribute('data-phone', res.web_service_phone) 
		},{});
	});
	function chunkCache(clearcache){
		plus.cache.calculate(function(size) {
			var cache = (size/1024/1024).toFixed(2) == 0  ? 0 : (size/1024/1024).toFixed(2);
			clearcache.querySelector('span').innerHTML = (size/1024/1024).toFixed(2)  + 'M';
		});
	}
	mui.plusReady(function () {
		plus.webview.currentWebview().addEventListener('show', function(){
			merchant = bexta.getStorage(MERCHANT);
			document.querySelector('#heads').src = merchant.logo;
			document.querySelector('#showname').innerHTML = merchant.shop_name;
		})
//	    document.querySelector('.version').innerHTML = "v" + plus.runtime.version;
	    var clearcache = document.querySelector('.calcatch');
		chunkCache(clearcache)
		clearcache.addEventListener('tap', function(){
			plus.cache.clear(function(){
				mui.toast("清除成功");
				clearcache.querySelector('span').innerHTML = 0 + 'M';
			});
		});
		
		document.querySelector('.signoutlist').addEventListener('tap', function(){
			mui.confirm("您确定要退出当前帐号吗？", TITLE, CONFIRM, function(item){
				if( item.index == 1 ){
					bexta.rmStorage(MERCHANT);
					mui.openWindow({
						id:'login',
						url:"login.html",
						show:{autoShow:true,aniShow:'zoom-fade-out'}
					})
				}
				
			});
		});
		
	});
	 mui.ready(function () {
	 	//联系客服
	 	//头象处理  uploadImage:function(files, extras, tips, url)
		document.querySelector('#heads').addEventListener('tap', function(){
	   		mui('#sheet1').popover('toggle');
	   	});	
	   	//相机
		mui('#sheet1').on('tap', '.callCamera', function() {
			var self = this;
			bexta.camera(function(p){
				plus.io.resolveLocalFileSystemURL(p, function(entry){
					plus.zip.compressImage({
						src:entry.toLocalURL(),
						dst:'_doc/b.jpg',
						overwrite:true,
						format:'jpg',
						quality:50,
						width:'480px',
						height:'auto'
					}, function(evt){
						mui.openWindow({
							id:'cropperPic',
							url:"cropperPic.html",
							extras:{
								imgSrc:evt.target
							},
							show:{aniShow:"pop-in"},
							waiting:{autoShow:false}
						});
					});
				}, function(e){
					mui.toast('读取拍照文件错误');
				});
			},['480px','480px']); 
			mui('#sheet1').popover('toggle');
		});
		//相册
		mui('#sheet1').on('tap', '.callalbum', function() {
			bexta.gallery(function(files){
				plus.zip.compressImage({
						src:files,
						dst:'_doc/b.jpg',
						overwrite:true,
						format:'jpg',
						quality:50,
						width:'480px',
						height:'auto'
					}, function(evt){
						mui.openWindow({
							id:'cropperPic',
							url:"cropperPic.html",
							extras:{
								imgSrc:evt.target
							},
							show:{aniShow:"pop-in"},
							waiting:{autoShow:false}
						});
					})
			});
			mui('#sheet1').popover('toggle');
		});
	 });
	 
	 
window.addEventListener('cropperImg', function(evt){
	if( !merchant ){
		merchant = bexta.getStorage(MERCHANT);
	}
	merchant['logo'] = evt.detail.resImg;
	bexta.setStorage(MERCHANT, merchant);
	document.querySelector('#heads').src = merchant.logo;
	//
	mui.fire(plus.webview.getWebviewById('index'), 'updataMsg');
});
</script>
</body>
</html>
